<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="jt.classic.system.user.IUser"%>
<%@ page import="jt.classic.system.group.IGroup"%>
<%@ page import="jt.classic.system.ISystem"%>
<%@ page import="jt.classic.system.group.GroupManager"%>
<%@ page import="java.util.List"%>
<%
	String context = jt.classic.system.ISystem.getContextPath();
	IUser user = ISystem.getSessionUser(request);
	
	if(ISystem.matchrole(user, "NSManager")){
		response.sendRedirect(context + "/system/tablequery/jsplist.jsp?queryKey=allfilelist");
	}else if(ISystem.matchrole(user, "ProjectManager")){
		StringBuffer groupIds = new StringBuffer();
		
		if(user.igroup() != null && user.igroup().hasChildGroup()){
			
			List list = null;
			
			GroupManager gm = new GroupManager();
			
			try{
				list = gm.findChildGroup(user.igroup().id());
			} catch(Exception ex){
				ISystem.catchException(ex);
			} finally{
				gm.clean();
			}
            
			if(list != null && !list.isEmpty()){
				for(int i = 0; i < list.size(); i++){
					IGroup group = (IGroup)list.get(i);
					groupIds.append(group.id());
					
					if(i < list.size() - 1){
						groupIds.append(",");
					}
				}
			}
		}
		response.sendRedirect(context + "/system/tablequery/jsplist.jsp?queryKey=filelist&childrenGroupIds=" + groupIds.toString());
	}
%>